using System;
using UnityEngine;
using System.Collections;

namespace UI
{
    public class PetTalentItem : MonoBehaviour
    {
        public UILabel talentDesc;
        public UILabel talentName;
        public GameObject whiteLine;
        public UISprite bg;

        private int bgHeight = 120;
        private int h = 26;

        public void SetTalent(string name,string desc)
        {
            talentName.text = TableTextBlo.GetText(name);
            var strDesc = TableTextBlo.GetText(desc);
            talentDesc.text = string.Format(TableTextBlo.GetText("ui_pet_talent_desc"), "1", "hah");
            Debug.Log("text:" + talentDesc.text);
            if(talentDesc.height > bgHeight)
            {
                bg.height = talentDesc.height;
            }
            SetWhiteLine();
        }
        public int PetTalentItemHeight
        {
            get
            {
                return bg.height;
            }
        }
        public void SetWhiteLine()
        {
             int y = -20;
            var lines = talentDesc.height / h;
            for(int i = 0; i< lines; i++)
            {
                var go = Instantiate(whiteLine);
                go.SetActive(true);
                go.transform.parent = talentDesc.transform;
                go.transform.localScale = new Vector3 (1,1,1);
                go.transform.localPosition = new Vector3(203, y, 0);
                y -=26;
            }
        }
    }
}